package club.justwill.single.persistence.jpo;

import club.justwill.single.persistence.support.ProjectIntroduceBase;

import javax.persistence.*;

/**
 * Created by luoyu on 15-12-24.
 */
@Entity
@Table(name = "project_introduce")
@NamedQueries({
        @NamedQuery(name="ProjectIntroduce.searchByProjectId",
                query="select pi from ProjectIntroduce pi where pi.projectId = :projectId"),
        @NamedQuery(name="ProjectIntroduce,searchProjectSupportReturn",
                query="select pi from ProjectIntroduce pi where pi.projectId = :projectId and pi.type = 20"),
        @NamedQuery(name="ProjectIntroduce.searchByIntroduceId",
                query="select pi from ProjectIntroduce pi where pi.id = :introduceId"),
})
public class ProjectIntroduce extends ProjectIntroduceBase {

    @Id
    @Column(name = "project_introduce_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long projectIntroduceId;

    //一个项目可以用多个介绍，介绍跟项目是多对一关系 多方
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "project_id", referencedColumnName = "project_id", insertable = false, updatable = false)
    private Projects projects;

    public Projects getProjects() {
        return projects;
    }

    public void setProjects(Projects projects) {
        this.projects = projects;
    }

    public long getProjectIntroduceId() {
        return projectIntroduceId;
    }

    public void setProjectIntroduceId(Long projectIntroduceId) {
        if(projectIntroduceId == null) {
            this.projectIntroduceId = 0L;
        } else {
            this.projectIntroduceId = projectIntroduceId;
        }
    }
}
